package android.tvtt.navigationmenu;

import android.content.Context;
import android.tvtt.yd360.R;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CustomNavigationAdapter extends ArrayAdapter<ItemMenuObject> {

	public CustomNavigationAdapter(Context context, int layout) {
		super(context, R.layout.item_menu_layout);
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v = convertView;
		ItemMenuObject mItem = this.getItem(position);

		if (v == null) {
			LayoutInflater lif = LayoutInflater.from(this.getContext());
			v = lif.inflate(R.layout.item_menu_layout, null);
		}

		ImageView mIcon = (ImageView) v.findViewById(R.id.imageView1);
		TextView mTitle = (TextView) v.findViewById(R.id.textView1);

		mIcon.setImageResource(mItem.getIconRes());
		mTitle.setText(mItem.getTitle());
		return v;
	}
}
